package com.ybfenpan.controller.admin.wealth;


import com.ybfenpan.controller.core.BaseController;
import com.ybfenpan.service.log.LogCenterUpService;
import com.ybfenpan.service.log.LogFutouService;
import com.ybfenpan.taglib.pagetag.Pagination;
import com.ybfenpan.utils.MapUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;


/**
 * Created by Administrator on 2016/3/25.
 */
@Controller

public class LogCenterUpListController extends BaseController {
    @Resource
    private LogCenterUpService logCenterUpService;
   
   
    @RequestMapping("admin/wealth/logCenterUpList.shtml")
    public String list(HttpServletRequest request) throws Exception{
        HashMap formMap = getParameterMap(request);
        String startDate = MapUtil.getString(formMap, "startDate");
        String endDate = MapUtil.getString(formMap, "endDate");
        String loginNameDiy=MapUtil.getString(formMap, "loginNameDiy");
        if(startDate!=null&&!startDate.equals("")&&endDate!=null&&!endDate.equals("")){
        	//+1天
        	 
        	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");//小写的mm表示的是分钟  
        	 
        	Date newEndDate=sdf.parse(endDate);  
        	
        	long temp=newEndDate.getTime()+24*60*60*1000;
			newEndDate=new Date(temp);
			
			String newEndDateString=sdf.format(newEndDate);  
        	formMap.put("where", " a.commitDate>= '"+startDate+"' and a.commitDate<= '"+newEndDateString+"'");	//  时间查询
        	

        	if(loginNameDiy!=null&&loginNameDiy!=""){
        		formMap.put("where", "  a.commitDate>= '"+startDate+"' and a.commitDate<= '"+newEndDateString+"' and b.loginName like '%"+loginNameDiy+"%'");			//未报单
            }
        }else {
        	if(loginNameDiy!=null&&loginNameDiy!=""){
        		formMap.put("where", "1=1 and b.loginName like '%"+loginNameDiy+"%'");			//未报单
        	}
		}
        formMap.put("pagination.orderBy"," a.id desc");  //排列
        Pagination page = logCenterUpService.queryForPageList("logCenterUpForPage",formMap);
        request.setAttribute(Pagination.pageBeanName, page);
        request.setAttribute("startDate", startDate);
        request.setAttribute("endDate", endDate);
        return "admin/wealth/logCenterUpList";
    }

    
}
